# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Rasmus Thomsen <oss@cogitri.dev>
pkgname=tectonic
pkgver=0.9.0
pkgrel=0
pkgdesc="Tectonic is a modernized, complete, self-contained TeX/LaTeX engine"
url="https://tectonic-typesetting.github.io"
# s390x, riscv64: rust
# 32-bit: SIGSEGVs in tests
arch="all !s390x !armhf !armv7 !x86 !riscv64"
license="MIT"
# needed for font things
depends="icu-data-full"
makedepends="
	cargo
	harfbuzz-dev
	openssl-dev
	fontconfig-dev
	"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/tectonic-typesetting/tectonic/archive/tectonic@$pkgver.tar.gz
	"
builddir="$srcdir/tectonic-tectonic-$pkgver"
options="!check" # needs unpackages ubuntu mono font

export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
export CARGO_PROFILE_RELEASE_LTO="true"
export CARGO_PROFILE_RELEASE_OPT_LEVEL="s"
export CARGO_PROFILE_RELEASE_PANIC="abort"

prepare() {
	default_prepare

	cargo fetch --locked
}

build() {
	cargo build --release --frozen --features=external-harfbuzz
}

check() {
	cargo test --frozen --features=external-harfbuzz
}

package() {
	install -Dm755 "$builddir"/target/release/tectonic "$pkgdir"/usr/bin/tectonic
}

sha512sums="
07c1b61dc764231eabbfa325089db2ed4bcead6699156e5aec8aded446276f42c00cace45419e0b3f15bc38a74a3590889060e1d011b2cebde3936207899cc30  tectonic-0.9.0.tar.gz
"
